<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="text">
	<br>
    <input type="text">
	<br>
	<input id="btn" type="button" value="获取文本框值">

	<script>
	//赋值
	var inputs = document.getElementsByTagName('input')
	for(var i = 0; i < inputs.length;i++){
		var input = inputs[i];
		if(input.type === 'text'){
			input.value=i;
		}
	}
	//点击获取
	var btn = document.getElementById('btn')
	btn.onclick = function(){
		var array = [];
		for(var i = 0; i < inputs.length;i++){
			var input = inputs[i]
			if(input.type === 'text'){
				array.push(input.value)
			}
		}
		alert(array.join('···'))
	}
	</script>
</body>
</html>